import React from "react";
import './index.css'
class ItemTodo extends React.Component{


//删除
handeDelede=(id)=>{

this.props.deleteTodo(id)

}
//修改
handleClick=(id)=>{

  let name=prompt('请输入修改的内容');
  this.props.changeTodo(id,name)

}
//true or folse
handeleChange=(id,e)=>{
    console.log(id)
this.props.updateTodo(id,e.target.checked)

}

  render(){
   const{id,name,done}=this.props;
  return(
   <li>
<label>
<input  type='checkbox' checked={done} onChange={ (e)=>this.handeleChange(id,e)}/>
</label>
    <span>{name}</span>

 <button onClick={()=>this.handleClick(id)}>修改</button>
 <button onClick={()=>this.handeDelede(id)}>删除</button>
   </li>
  )
  }
}

export default ItemTodo;